<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 3月27日
 * Time: 18:16
 */
namespace app\api\controller;

use app\api\model\CloudmobData;
use app\api\model\DofunData;
use app\api\model\DotiappData;
use app\api\model\InfimobData;
use app\api\model\MobuppsData;
use think\Request;

class Approval
{


    /*
     * 批量更新API导入的数据
     */
    public function index()
    {

        //$mod = new DofunData;
        //$mod = new CloudmobData;
        //$mod = new DotiappData;
        //$mod = new InfimobData;
        $mod = new MobuppsData;
        $list = $mod->where(array('offer_status'=>1))->field('offer_id')->select()->toArray();
        foreach($list as $v)
        {
            if($v['offer_id'] > 0){
                $res = $this->updateOffer($v['offer_id']);
                if($res['code'] != 0){
                    dump($res);
                }
            }
        }


    }

    private function updateOffer($offer_id)
    {
        $username = 'idvert';
        $security_token = '7658532c77854965ae4ebc90f6ae8d09';

        $url = 'http://idvert.api.offerslook.com/v1/offers/'.$offer_id;

        $data = array();
        /*$data['offer'] = array(
            'offer_approval' => 2,
        );*/
        $data['offer_category']['name'] = 'API';

        $res = puturl($url,$data,$username,$security_token);

        return json_decode($res,true);
    }

}